// Copyright 2012. InMobi. All Rights reserved

package com.inmobi.sharedlock;

/**
 * Interface for representing something calculates average
 * over a set of values. The intrinsic behaviour is up to the
 * implementation. But unless otherwise noted average is the
 * average of all values inserted.
 *
 * Note that these are just demo :) rarely will an average interface
 * will be this simple.
 */
public interface AverageCalculator {

  /**
   * Adds a new value to the system.
   * @param value Try to keep actual size low enough that sum of all of
   *              values doesn't exceed double's maximum value.
   */
  void addValue(long value);

  /**
   * Computes average. If no values are inserted, this returns 0.
   * If the implementation doesn't look at all the values, then it
   * means no candidate values are found, which could also mean a default 0.
   * @return average value of the values inserted.
   */
  double getAverage();
}
